home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / diskmags / 0022-3.564 / dmg-0143 / articles / sample.doc < prev    next >
Text File  |  1997-04-16  |  2KB  |  94 lines

  1.  
  2.                        -------------------
  3.                        STE SAMPLE PLAYING!
  4.                        -------------------
  5.                                    Written by Paul Bramwell
  6.  
  7. Those of you with an STE like me will feel the lack of support in 
  8. games, this to change soon, you may have a few STE Demos like 
  9. Black Cats Demo or whatever, these use the enhanced sound chip 
  10. and sample chip the DMA chip.
  11.  
  12. These routines supplied will also use the DMA chip, which enables 
  13. us to get on with something else while we are playing a sample.
  14.  
  15. The routines supplied are based around the Mastersound playback 
  16. routines.
  17.  
  18.                           ------------
  19.                           HOW TO DO IT
  20.                           ------------
  21.  
  22. First of all we need to set up some memory for our sample, we do 
  23. this using DIM A%(Value), you should have come across this by 
  24. now.
  25.  
  26.  
  27. DIM Sample%(5000)               ! Sets up some memory
  28. sample%=VARPTR(b%(0))           
  29.  
  30. The next step is to load the sample into this space, we do this 
  31. using the Bmove command.
  32.  
  33. BLOAD "backbed.sam",sample%     
  34.  
  35. The length of the sample supplied is about 30k, so we setup this 
  36. value as follows
  37.  
  38. length%=30000                    ! Length of sample
  39. dma%=&HFF8901                    ! Sets up DMA value
  40.  
  41. Now we need to reset the DMA chip so we SPOKE it,
  42.  
  43. SPOKE dma%,0                     ! Resets DMA
  44.  
  45. Next we setup the sample rate and a single mono channel.
  46.  
  47. SPOKE dma%+32,&H81
  48.  
  49. SPOKE dma%+2,sample%/&H10000      ! Start, count addresses
  50. SPOKE dma%+4,sample%/&H100
  51. SPOKE dma%+6,sample% AND &HFF
  52. SPOKE dma%+8,sample%/&H10000
  53. SPOKE dma%+&HA,sample%/&H100
  54. SPOKE dma%+&HC,sample% AND &HFF
  55. SPOKE dma%+&HE,(sample%+length%)/&H10000
  56. SPOKE dma%+&H10,(sample%+length%)/&H100
  57. SPOKE dma%+&H12,(sample%+length%) AND &HFF
  58.  
  59. Now you can put your main program here and then recall the sample 
  60. using
  61.  
  62. SPOKE dma%,1
  63. FOR n%=0 TO 50
  64.   VSYNC
  65. NEXT n%
  66.  
  67.  
  68. And thats all there is to it!
  69.  
  70. To change the playback rate we just do this:
  71.  
  72. FOR speed%=0 TO 3
  73.   SPOKE dma%+32,&H80+speed%
  74.  
  75.   SPOKE dma%,3                          ! Loop DMA
  76.  
  77.   FOR n%=0 TO 100
  78.     VSYNC
  79.   NEXT n%
  80. NEXT speed%
  81.  
  82.  
  83. SPOKE dma%,0                            ! End sound
  84. End
  85.  
  86.  
  87. If you have a long sample, and you want it interupt driven just 
  88. take out the SPOKE dma%,0 out, this will make the sample keep 
  89. playing.
  90.  
  91. The listing is on the disk, in the GOODIES\GFA folders.
  92.  
  93.  
  94.